var os=navigator.platform.toLowerCase();
	var uant=navigator.userAgent.toLowerCase();
	if(uant.indexOf("android")>0||os=="iphone"){
		location.href="index_mobile";
	}
$(function(){
	$("#uname").focus();
	setMiddleheight();
	$(window).resize(function() {
		setMiddleheight();
	})
	$("#denglu").hover(function(){
		$("#denglu").removeClass("denglukuang");
		$("#denglu").addClass("dengluzhong");
	},function(){
		$("#denglu").removeClass("dengluzhong");
		$("#denglu").addClass("denglukuang");
	});
})

function setMiddleheight(){
	var hh=$(window).height();
	if(hh<600){
		$("#main").height(520);
	}else{
		$("#main").height(hh-180);
	}
}

function login(){
	var username = $("#uname").val();
	var pwd = $("#pwd").val();
	if (username == "" || username == null) {
		alert("请输入用户名！");
		return;
	}
	if (pwd == "" || pwd == null) {
		alert("请输入密码！");
		return;
	}
	$("#denglu").hide();
	$("#dengluz").show();
	$.ajax({
		url:"userLoginSub",
		type:"get",
		contentType:"application/json",
		dataType : 'json',
		async:true,
		data:{userName:username,psw:pwd},
		success:function(msg){
			var errmsg=msg.errorMsg;
			if(errmsg==""){
					location.href="loginSub";
			}
			else{
				alert(errmsg);
				$("#denglu").show();
				$("#dengluz").hide();
			}
		},
		error:function(xhr, type, exception){
			$("#denglu").show();
			$("#dengluz").hide();
		}
	});
}
function enterkey() {
	if (window.event.keyCode == 13) {
		login();
	}
}